/**
* File Name: globle_pthrd.c
* Auther: Jichang
* Environment: Fedora 7 server
* Pthread share the same globle value.
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<pthread.h>

int var = 100; // globle value.

void *tfn(void *arg) 
{
	var = 200;
	printf("thread\n");
	return NULL;
}

int main(int argc, char *argv[])
{
	printf("At first var=%d\n", var);

	pthread_t tid;
	pthread_create(&tid, NULL, tfn, NULL);
	sleep(1);

	printf("After pthread_create, var=%d\n", var);
	
	return 0;
}

